package com.chcit.custom;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

public class MyTextView extends View {
    public MyTextView(Context context) {
        super(context);
    }

    public MyTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int baseLineX = 0 ;
        int baseLineY = 600 ;
        //画基绞
        Paint paint = new Paint () ;
        paint . setColor(Color. RED) ;
        canvas . drawLine (baseLineX, baseLineX , 3000 , baseLineY , paint);
        //写文字
        paint.setColor(Color.GREEN);
        paint.setTextSize(120); // 以px 为单位
        canvas.drawText( " harvic\'s blog", baseLineX , baseLineY , paint);
    }
}
